package top.malaoshi.jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

/**
 * 高级封装类
 * 如果自动提交，执行增删改查后，会自动关闭数据库连接
 * 如果需要在一个连接中，执行多次增删改查操作，需要设置为非自动提交，增删改查后，需要手动关闭连接
 */
public interface DbSession {

    public List<Record> query(String sql, Object ... objects ) throws SQLException;

    public <E> List<E> query(Class clazz,String sql,Object ... params) throws SQLException ;

    public List<Record> queryTag(String sql,  Object obj) throws SQLException;

    public <E> List<E> queryTag(Class clazz,String sql, Object obj) throws SQLException;

    public int update(String sql,Object ... objects) throws SQLException;

    public int updateTag(String sql , Object obj ) throws SQLException;

    public void close() throws SQLException;

    public void commit() throws SQLException;

    public void rollback() throws SQLException;

    public void setAutoCommit(boolean autoCommit) throws SQLException;

    public Connection getConnection();
}
